/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-11-06
 * Time: 21:15
 */
class Solution8 {
    public int takeAttendance(int[] records) {
        int left = 0 , n = records.length , right = records.length-1;
        if(records[0] != 0){
            return 0;
        }
        if(records[n-1] == n-1){
            return n;
        }
        while(left < right){
            int mid = left + (right - left)/2;
            if(records[mid] - mid <= 0){
                left = mid + 1;
            }else{
                right = mid ;
            }
        }
        return right;
    }
}
public class Test8 {
}
